﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chinaer.Web
{
    public partial class City : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Bind();
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var result = CommonService.GetChinaerService.AddCity(new DTO.CityDTO()
             {
                 CityName = this.txtName.Text.Trim(),
                 CreateTime = DateTime.Now,
                 IsDelete = false,
                 IsUse = true,
                 ProvinceID = this.ddlProvince.SelectedValue

             });
            Response.Write(result);
            Bind();
        }
        private void Bind()
        {

            List<DTO.ProvinceDTO> listProvince = CommonService.GetChinaerService.GetProvinceByCountryID("2014101423075144353ae2c49a51441a", "");
            this.ddlProvince.DataSource = listProvince;
            this.ddlProvince.DataTextField = "Name";
            this.ddlProvince.DataValueField = "ID";
            this.ddlProvince.DataBind();
        }
    }
}